﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class Main : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (HttpContext.Current.Request.ServerVariables["URL"].ToString().Contains("Login"))
            TableNavigate.Visible = false;
        else
            TableNavigate.Visible = true;

        if (!Page.IsPostBack)
        {
            DataTable dt = (DataTable)Session["UserInfo"];

            if (dt != null)
            {
                LabelUserName.Text = dt.Rows[0]["UserName"].ToString();

                HyperLinkManageUser.Visible = Convert.ToBoolean(dt.Rows[0]["IsAdmin"].ToString());
                HyperLinkUserList.Visible = Convert.ToBoolean(dt.Rows[0]["IsAdmin"].ToString());
            }
        }
    }

    protected void LinkButtonLogout_Click(object sender, EventArgs e)
    {
        Session["IsUserLogined"] = null;
        Response.Redirect("~/Login/Login.aspx");
    }
}
